import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.Window 2.2

Rectangle {
    id: rec
    //width: 800
    width: parent.width
    height: 48
    radius: 10
    RowLayout {
        id: rowLayout
        height: 48
        width:   rec.width
        Image {
            id: avatar
            source: "qrc:images/user1.png"
            fillMode: Image.Stretch

            height: 48
            width: 48

        }
        Text {
            id: name
            text: qsTr(libname)
            elide: Text.ElideLeft
            font.pixelSize: 20
            width: 60
            height: 48

        }
        Item {
            Layout.fillWidth: true;
        }
        ColumnLayout {
            id: columnLayout1

            Text {
                id: talktime
                text: ""+talk_time
                horizontalAlignment: Text.AlignRight
                Layout.fillWidth: false
                font.pixelSize: 12
                Layout.alignment: Qt.AlignRight
            }

            Image {
                width: 16
                height: 16
                sourceSize.height: 20
                sourceSize.width: 20
                source: getImgSrc()
                Layout.alignment: Qt.AlignRight
            }

        }

    }
    MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: {
            talk_notify.open();
        }


    }
    function getImgSrc() {

        if(talk_type=="来电" && talk_res=="已接") {
            return "qrc:images/call_in_green.png"
        }else if(talk_type=="来电") {
            return "qrc:images/call_in_red.png"
        }else if(talk_res=="已接") {
            return "qrc:images/call_out_green.png"
        }else {
            return "qrc:images/call_out_red.png"
        }
    }
    NotifyPopup {
        id: talk_notify
        text: qsTr("对方不在线")
    }


}
